package com.xiaoka.ins.corp.api.zkic.service;

import com.xiaoka.ins.corp.api.utils.BaseUtils;
import com.xiaoka.ins.corp.api.zkic.dto.base.BasePartDto;
import com.xiaoka.ins.corp.api.zkic.dto.base.BodyDto;
import com.xiaoka.ins.corp.api.zkic.dto.base.HeaderDto;
import com.xiaoka.ins.corp.api.zkic.dto.base.PacketDto;

/**
 * @author 
 * 紫金
 */
public class ZkicService {
	
	public PacketDto getVehicleType(String brandName)
	{
		//新车标志为0，只要你的brandname是对的，车架号和VINNO随便输
		PacketDto request = new PacketDto();
		//报文头
		HeaderDto headerDto = new HeaderDto();
		headerDto.setTransType("S0104");
		//唯一请求标识
		headerDto.setTransID(BaseUtils.getUniqueId());
		headerDto.setTransDate("");
		
		request.setHead(headerDto);
		//报文体	
		BodyDto bodyDto = new BodyDto();
		BasePartDto basePartDto = new BasePartDto();
		//
		basePartDto.setComCode("");
		basePartDto.setRiskCode("0505");
		basePartDto.setCarKindCode("A0");
		//首次登记日期
		basePartDto.setEnrollDate("2013-09-18");
		basePartDto.setLicenseNo("");
		basePartDto.setLicenseType("02");
		basePartDto.setVehicleBrand1(brandName);
		basePartDto.setEnginNo("");
		basePartDto.setNewVehicleFlag("0");
		basePartDto.setEcdemicVehicleFlag("0");
		basePartDto.setSalesChannelCode("");
		
		bodyDto.setBasePart(basePartDto);
		request.setBody(bodyDto);
		
		String requestXml = BaseUtils.beanToXml(request, PacketDto.class);
		return null;
	}
 
//
//    getServerXMLResponse response;
//    string requestXml = request.ToSerializeXml<vehiclerequest.VehicleTypeRequest>();
//    //车型查询接口
//    response = ZkingServiceProxy.Execute(service =>
//        service.getServerXML(new Yangche.Third.Service.Zking.getServerXMLRequest()
//        {
//            Body = new Yangche.Third.Service.Zking.getServerXMLRequestBody()
//            {
//                xmlStr = requestXml
//            }
//        }));
//    //<?xml version="1.0" encoding="UTF-8"?><Packet type="" version=""><Head><TransType>S0104</TransType><TransID>1506011629064365948</TransID><TransDate>2015-06-01 16:29:06</TransDate><RequestType>02</RequestType><ErrorCode>0000</ErrorCode><ErrorMessage>成功</ErrorMessage></Head><Body><VehicleModelList><VehicleModelData><CarKind>轿车类</CarKind><ModelCode>SKAAFD0042</ModelCode><ModelName>明锐SVW7166FSD</ModelName><ModelDesc>轿车,手自一体 逸杰版 国IV (节能补贴)</ModelDesc><Brand>上海大众斯柯达</Brand><ImportFlag>合资</ImportFlag><MarketYear></MarketYear><SeatCount>5</SeatCount><VehicleWeight>1322</VehicleWeight><VehicleTonnage></VehicleTonnage><ExhaustCapacity>1598.0</ExhaustCapacity><Power></Power><TransmissionType></TransmissionType><AbsFlag></AbsFlag><PurchasePrice>137300</PurchasePrice><AirBagNum></AirBagNum><AlarmFlag></AlarmFlag><IsPriced></IsPriced><RiskFlag></RiskFlag><RefCode1>SKAAFD0042</RefCode1><RefCode2>MRD1042SHD</RefCode2><Remark></Remark><CarOwner>刘怡芳</CarOwner><EnrollDate>20110524</EnrollDate><EngineNo>067066</EngineNo><VINNo>LSVNY41Z3B2489016</VINNo><LicenseNo>沪KC8291</LicenseNo><LicenseKindCode></LicenseKindCode><MakeDate></MakeDate><SearchSequenceNo>39ZKIC01150000000000125030034E</SearchSequenceNo><OriCarKindName></OriCarKindName></VehicleModelData><VehicleModelData><CarKind>轿车类</CarKind><ModelCode>SKAAFD0044</ModelCode><ModelName>明锐SVW7166FSD</ModelName><ModelDesc>轿车,手自一体 逸俊版 国IV (节能补贴)</ModelDesc><Brand>上海大众斯柯达</Brand><ImportFlag>合资</ImportFlag><MarketYear></MarketYear><SeatCount>5</SeatCount><VehicleWeight>1322</VehicleWeight><VehicleTonnage></VehicleTonnage><ExhaustCapacity>1598.0</ExhaustCapacity><Power></Power><TransmissionType></TransmissionType><AbsFlag></AbsFlag><PurchasePrice>146500</PurchasePrice><AirBagNum></AirBagNum><AlarmFlag></AlarmFlag><IsPriced></IsPriced><RiskFlag></RiskFlag><RefCode1>SKAAFD0044</RefCode1><RefCode2>MRD1044SHD</RefCode2><Remark></Remark><CarOwner>刘怡芳</CarOwner><EnrollDate>20110524</EnrollDate><EngineNo>067066</EngineNo><VINNo>LSVNY41Z3B2489016</VINNo><LicenseNo>沪KC8291</LicenseNo><LicenseKindCode></LicenseKindCode><MakeDate></MakeDate><SearchSequenceNo>39ZKIC01150000000000125030034E</SearchSequenceNo><OriCarKindName></OriCarKindName></VehicleModelData></VehicleModelList></Body></Packet>
//    List<VehicleTypeDTO> vehiclelist = new List<VehicleTypeDTO>();
//    vehicleresponse.VehicleTypeResponse insRetData = (vehicleresponse.VehicleTypeResponse)response.Body.getServerXMLReturn.ToDeserializeXml<vehicleresponse.VehicleTypeResponse>();
//    if (insRetData.Head.ErrorCode == ZKICConfig.returnSuccessCode && null != insRetData.Body.VehicleModelList)
//    {
//        foreach (var item in insRetData.Body.VehicleModelList.VehicleModelData)
//        {
//            vehiclelist.Add(new VehicleTypeDTO()
//            {
//                brandName = item.ModelName,
//                exhaustMeasure = item.ExhaustCapacity.ToDecimal() / 1000,
//                vehicleId = item.RefCode1,
//                vehicleQuality = (item.VehicleWeight.ToDecimal() / 1000).ToString(),
//                vehicleSeat = item.SeatCount.ToInt(),
//                vehiclePower = item.Power.ToDecimal(),
//                purchasePriceIncludeTax = item.PurchasePrice.ToDecimal()
//            });
//        }
//        ret.data = vehiclelist;
//    }
//    else
//    {
//        throw new ExceptionBase(ErrorCode.NotFindModelsType, insRetData.Head.ErrorMessage);
//    }
	
}
